#!/usr/bin/env python
# -*- coding: utf-8 -*- 

'''
Created on Dec 7, 2011

@author: Dulei
'''

import random

def get_input():
 
    qst_lvl = raw_input(">>请输入算数题的难度(例：10以内加减法输入 10)(默认值：10)：")
    add_num = raw_input(">>请输入加法题的数量(默认值：10)：")
    sub_num = raw_input(">>请输入减法题的数量(默认值：10)：")
    if not qst_lvl:
        qst_lvl = 10
    else:
        qst_lvl = int(qst_lvl)
        
    if not add_num:
        add_num = 10
    else:
        add_num = int(add_num)
            
    if not sub_num:
        sub_num = 10
    else:
        sub_num = int(sub_num)
        
    print "-----------------------------------------------"
    return { "qst_lvl" : qst_lvl, "add_num" : add_num, "sub_num" : sub_num }

def add_gen(num):
    add_qlist = []
    
    for i in range(0, num.get("qst_lvl")+1):
        for j in range(0, num.get("qst_lvl")+1):
            #i=0, j=0
            if (i+j) >= num.get("qst_lvl"):
                continue
            else:
                q = str(i) + " " + "+" + " " + str(j) + " " + "=" + " " + str(i+j)
                add_qlist.append(q)
                
    #for n in range(0, num.get("add_num")):
    #    print random.choice(add_qlist)
    
    add_qlist = random.sample(add_qlist, num.get("add_num"))
    
    return add_qlist

def sub_gen(num):
    sub_qlist = []

    for i in range(num.get("qst_lvl"), -1, -1): 
        for j in range(num.get("qst_lvl"), -1, -1):
            if ((i-j) < 0) or ((i-j) > num.get("qst_lvl")):
                continue
            else:
                q =  str(i) + " " + "-" + " " + str(j) + " " + "=" + " " + str(i-j)
                sub_qlist.append(q)
                
    #for n in range(0, num.get("sub_num")):
    #    print random.choice(sub_qlist)
        
    sub_qlist = random.sample(sub_qlist, num.get("sub_num"))
    
    return sub_qlist

def stdfile(qlist):
    for i in range(0, len(qlist)):
        print qlist[i]

def total_gen(add_qlist, sub_qlist):
    
    qlist = add_qlist + sub_qlist
    random.shuffle(qlist)
    return qlist

if __name__ == '__main__':
    
    num = get_input()

    if num.get("add_num") != 0:
        add_qlist = add_gen(num)
 
    if num.get("sub_num") != 0:
        sub_qlist = sub_gen(num)

    qlist = total_gen(add_qlist, sub_qlist)
    
    stdfile(qlist)
    